﻿using Service;
using Microsoft.AspNetCore.Mvc;

namespace Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UserController : BaseController
    {
        private IUserInfoService _userInfoService;

        public UserController(IUserInfoService userInfoService)
        {
            _userInfoService = userInfoService;
        }

        [HttpGet]
        public string word()
        {
            //logservice.LogInfomation("Hello Word!");
            return "Hello Word!";
        }
        [HttpGet]
        public string Login(string account, string password)
        {
            var user = _userInfoService.Login(account,password);
            if(user == null)
            {
                return "用户名密码错误";
            }
            else
            {
                return "登录成功";
            }
        }
        [HttpPost]
        public ApiModel Find(string nickname)
        {
            var user = _userInfoService.Find(nickname);
            if(user == null)
            {
                return apiModel(Status.Error,"没有此用户");
            }
            else{
                return apiModel(Status.Success, "",user);
            }
        }
        
    }
}
